N, Q = map(int, input().split())

# 一次性读入所有初始值
arr = [0]+list(map(int, input().split()))

def operate(t, l, r, k=None):
    global arr, cnt
    if t == 1 and k is not None:
        # 区间加法操作
        for i in range(l, r+1):
            arr[i] += k
    elif t == 2:
        print(sum(arr[l:r+1]))

for _ in range(Q):
    input_data = list(map(int, input().split()))
    if len(input_data) == 4:
        operate(*input_data)
    else:
        # 对于只有三个参数的情况，直接解包调用
        operate(*input_data, k=None)